#include <windows.h>
#include <stdio.h>
#include <conio.h>
#include <stdlib.h>
#include <time.h>
#include <math.h>
int main()
{
	int x, y, a, b, where, fire, foeX, foeY;
	int i;
	i = 0;
	x = 20;
	y = 10;
	foeX = 30;
	foeY = 16;
	where = 2;
	fire = 0;
	char input;
	START:if (i == 0)
	{
		printf("H");
		Sleep(150);
		printf("e");
		Sleep(150);
		printf("l");
		Sleep(150);
		printf("l");
		Sleep(150);
		printf("o");
		Sleep(150);
		printf(" ");
		Sleep(150);
		printf("w");
		Sleep(150);
		printf("o");
		Sleep(150);
		printf("r");
		Sleep(150);
		printf("l");
		Sleep(150);
		printf("d\n");
		Sleep(150);
		printf("Press any key to start this game_\n");
		Sleep(150);
		system("pause");
	}
	while (i <= 15)
	{
		i++;
		printf("■");
		Sleep(80);
	}
	printf("\nOVER!");
	Sleep(50);
	i = 0;
	GAME:while (1)
	{
		system("cls");
		if (x == foeX && y == foeY)
		{
			x = 20;
			y = 10;
			break;
		}
		printf("X:%d | Y:%d | 方向状态:%d | 输出状态:%d\n", x, y, where, fire);
		for (b = 0; b <= 21; b++)
		{
			for (a = 0; a <= 38; a++)
			{
				if (fire == 1 && where == 2 && a == (x - 1) && b < (y - 1))
				{
					printf("○");
				}
				else
				{
					if (fire == 1 && where == 1 && a < (x - 1) && b == (y - 1))
					{
						printf("○");
					}
					else
					{
						if ((x - 1) == a && (y - 1) == b)
				 		{
							printf("♀");
						}
						else
						{
							if (where == 4 && fire == 1 && a > (x - 1) && b == (y - 1))
							{
								printf("○");
							}
							else
							{
								if (fire == 1 && where == 3 && a == (x - 1) && b > (y - 1))
								{
									printf("○");
								}
								else
								{
									if ((foeX - 1) == a && (foeY - 1) == b)
									{
										printf("☆");
									}
									else
									{
										printf("  ");
									}
								}
							}
						}
					}
				}
			}
			printf("\n");
		}
		fire = 0;
		input = _getch();
		if (input == 'w')
		{
			y--;
			where = 2;
			if (y < 1)
			{
				y = 1;
			}
		}
		else
		{
			if (input == 's')
			{
				y++;
				where = 3;
				if (y > 22)
				{
					y = 22;
				}
			}
			else
			{
				if (input == 'a')
				{
					x--;
					where = 1;
					if (x < 1)
					{
						x = 1;
					}
				}
				else
				{
					if (input == 'd')
					{
						x++;
						where = 4;
						if (x > 39)
						{
							x = 39;
						}
					}
					else
					{
						if (input = ' ')
						{
							fire = 1;
						}
					}
				}
			}
		}
	}
	system("cls");
	printf("Game Over!");
	system("pause");
	goto GAME;
}